package com.wzk.travelspringboot.enumerate;

/**
 * @Author: WangZiKang
 * @Date: 2025/1/14 20:12
 */
public enum NoticeTypeEnum {

    COMMON(1,"普通公告"),
    VITAL(2,"重要公告");
    private final int code;
    private final String description;

    // 构造函数
    NoticeTypeEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取code值
    public int getCode() {
        return code;
    }

    // 获取description值
    public String getDescription() {
        return description;
    }

    // 根据code值获取对应的描述
    public static String fromCode(int code) {
        for (NoticeTypeEnum typeEnum : NoticeTypeEnum.values()) {
            if (typeEnum.getCode() == code) {
                return typeEnum.getDescription();
            }
        }
        return COMMON.getDescription(); // 如果未匹配，返回普通
    }
}
